1 module directx.d3d8;
2 
3 version(Windows):
4 version(Direct3D_8):
5 
6 import directx.win32;
7 import directx.com;
8 import directx.d3dcommon;
9 
10 extern (C++) interface IDirect3D8 : IUnknown {
11     HRESULT RegisterSoftwareDevice(void* pInitializeFunction);
12     UINT GetAdapterCount();
13     HRESULT GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier);
14     UINT GetAdapterModeCount(UINT Adapter);
15     HRESULT EnumAdapterModes(UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode);
16     HRESULT GetAdapterDisplayMode(UINT Adapter,D3DDISPLAYMODE* pMode);
17     HRESULT CheckDeviceType(UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed);
18     HRESULT CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat);
19     HRESULT CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType);
20     HRESULT CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat);
21     HRESULT GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps);
22     HMONITOR GetAdapterMonitor(UINT Adapter);
23     HRESULT CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8* ppReturnedDeviceInterface);
24 }
25 
26 extern (C++) interface IDirect3DDevice8 : IUnknown {
27     HRESULT TestCooperativeLevel();
28     UINT GetAvailableTextureMem();
29     HRESULT ResourceManagerDiscardBytes(DWORD Bytes);
30     HRESULT GetDirect3D(IDirect3D8* ppD3D8);
31     HRESULT GetDeviceCaps(D3DCAPS8* pCaps);
32     HRESULT GetDisplayMode(D3DDISPLAYMODE* pMode);
33     HRESULT GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters);
34     HRESULT SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8 pCursorBitmap);
35     void SetCursorPosition(int X,int Y,DWORD Flags);
36     BOOL ShowCursor(BOOL bShow);
37     HRESULT CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8* pSwapChain);
38     HRESULT Reset(D3DPRESENT_PARAMETERS* pPresentationParameters);
39     HRESULT Present(const(RECT)* pSourceRect,const(RECT)* pDestRect,HWND hDestWindowOverride,const(RGNDATA)* pDirtyRegion);
40     HRESULT GetBackBuffer(UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8* ppBackBuffer);
41     HRESULT GetRasterStatus(D3DRASTER_STATUS* pRasterStatus);
42     void SetGammaRamp(DWORD Flags,const(D3DGAMMARAMP)* pRamp);
43     void GetGammaRamp(D3DGAMMARAMP* pRamp);
44     HRESULT CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8* ppTexture);
45     HRESULT CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8* ppVolumeTexture);
46     HRESULT CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8* ppCubeTexture);
47     HRESULT CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8* ppVertexBuffer);
48     HRESULT CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8* ppIndexBuffer);
49     HRESULT CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8* ppSurface);
50     HRESULT CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8* ppSurface);
51     HRESULT CreateImageSurface(UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8* ppSurface);
52     HRESULT CopyRects(IDirect3DSurface8 pSourceSurface,const(RECT)* pSourceRectsArray,UINT cRects,IDirect3DSurface8 pDestinationSurface,const(POINT)* pDestPointsArray);
53     HRESULT UpdateTexture(IDirect3DBaseTexture8 pSourceTexture,IDirect3DBaseTexture8 pDestinationTexture);
54     HRESULT GetFrontBuffer(IDirect3DSurface8 pDestSurface);
55     HRESULT SetRenderTarget(IDirect3DSurface8 pRenderTarget,IDirect3DSurface8 pNewZStencil);
56     HRESULT GetRenderTarget(IDirect3DSurface8* ppRenderTarget);
57     HRESULT GetDepthStencilSurface(IDirect3DSurface8* ppZStencilSurface);
58     HRESULT BeginScene();
59     HRESULT EndScene();
60     HRESULT Clear(DWORD Count,const(D3DRECT)* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil);
61     HRESULT SetTransform(D3DTRANSFORMSTATETYPE State,const(D3DMATRIX)* pMatrix);
62     HRESULT GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix);
63     HRESULT MultiplyTransform(D3DTRANSFORMSTATETYPE,const(D3DMATRIX)*);
64     HRESULT SetViewport(const(D3DVIEWPORT8)* pViewport);
65     HRESULT GetViewport(D3DVIEWPORT8* pViewport);
66     HRESULT SetMaterial(const(D3DMATERIAL8)* pMaterial);
67     HRESULT GetMaterial(D3DMATERIAL8* pMaterial);
68     HRESULT SetLight(DWORD Index,const(D3DLIGHT8)*);
69     HRESULT GetLight(DWORD Index,D3DLIGHT8*);
70     HRESULT LightEnable(DWORD Index,BOOL Enable);
71     HRESULT GetLightEnable(DWORD Index,BOOL* pEnable);
72     HRESULT SetClipPlane(DWORD Index,const(float)* pPlane);
73     HRESULT GetClipPlane(DWORD Index,float* pPlane);
74     HRESULT SetRenderState(D3DRENDERSTATETYPE State,DWORD Value);
75     HRESULT GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue);
76     HRESULT BeginStateBlock();
77     HRESULT EndStateBlock(DWORD* pToken);
78     HRESULT ApplyStateBlock(DWORD Token);
79     HRESULT CaptureStateBlock(DWORD Token);
80     HRESULT DeleteStateBlock(DWORD Token);
81     HRESULT CreateStateBlock(D3DSTATEBLOCKTYPE Type,DWORD* pToken);
82     HRESULT SetClipStatus(const(D3DCLIPSTATUS8)* pClipStatus);
83     HRESULT GetClipStatus(D3DCLIPSTATUS8* pClipStatus);
84     HRESULT GetTexture(DWORD Stage,IDirect3DBaseTexture8* ppTexture);
85     HRESULT SetTexture(DWORD Stage,IDirect3DBaseTexture8 pTexture);
86     HRESULT GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue);
87     HRESULT SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
88     HRESULT ValidateDevice(DWORD* pNumPasses);
89     HRESULT GetInfo(DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize);
90     HRESULT SetPaletteEntries(UINT PaletteNumber,const(PALETTEENTRY)* pEntries);
91     HRESULT GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries);
92     HRESULT SetCurrentTexturePalette(UINT PaletteNumber);
93     HRESULT GetCurrentTexturePalette(UINT *PaletteNumber);
94     HRESULT DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount);
95     HRESULT DrawIndexedPrimitive(D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount);
96     HRESULT DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,const(void)* pVertexStreamZeroData,UINT VertexStreamZeroStride);
97     HRESULT DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,const(void)* pIndexData,D3DFORMAT IndexDataFormat,const(void)* pVertexStreamZeroData,UINT VertexStreamZeroStride);
98     HRESULT ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8 pDestBuffer,DWORD Flags);
99     HRESULT CreateVertexShader(const(DWORD)* pDeclaration,const(DWORD)* pFunction,DWORD* pHandle,DWORD Usage);
100     HRESULT SetVertexShader(DWORD Handle);
101     HRESULT GetVertexShader(DWORD* pHandle);
102     HRESULT DeleteVertexShader(DWORD Handle);
103     HRESULT SetVertexShaderConstant(DWORD Register,const(void)* pConstantData,DWORD ConstantCount);
104     HRESULT GetVertexShaderConstant(DWORD Register,void* pConstantData,DWORD ConstantCount);
105     HRESULT GetVertexShaderDeclaration(DWORD Handle,void* pData,DWORD* pSizeOfData);
106     HRESULT GetVertexShaderFunction(DWORD Handle,void* pData,DWORD* pSizeOfData);
107     HRESULT SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer8 pStreamData,UINT Stride);
108     HRESULT GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer8* ppStreamData,UINT* pStride);
109     HRESULT SetIndices(IDirect3DIndexBuffer8 pIndexData,UINT BaseVertexIndex);
110     HRESULT GetIndices(IDirect3DIndexBuffer8* ppIndexData,UINT* pBaseVertexIndex);
111     HRESULT CreatePixelShader(const(DWORD)* pFunction,DWORD* pHandle);
112     HRESULT SetPixelShader(DWORD Handle);
113     HRESULT GetPixelShader(DWORD* pHandle);
114     HRESULT DeletePixelShader(DWORD Handle);
115     HRESULT SetPixelShaderConstant(DWORD Register,const(void)* pConstantData,DWORD ConstantCount);
116     HRESULT GetPixelShaderConstant(DWORD Register,void* pConstantData,DWORD ConstantCount);
117     HRESULT GetPixelShaderFunction(DWORD Handle,void* pData,DWORD* pSizeOfData);
118     HRESULT DrawRectPatch(UINT Handle,const(float)* pNumSegs,const(D3DRECTPATCH_INFO)* pRectPatchInfo);
119     HRESULT DrawTriPatch(UINT Handle,const(float)* pNumSegs,const(D3DTRIPATCH_INFO)* pTriPatchInfo);
120     HRESULT DeletePatch(UINT Handle);
121 }
122 
123 extern (C++) interface IDirect3DSwapChain8 : IUnknown {
124     HRESULT Present(const(RECT)* pSourceRect,const(RECT)* pDestRect,HWND hDestWindowOverride,const(RGNDATA)* pDirtyRegion);
125     HRESULT GetBackBuffer(UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8* ppBackBuffer);
126 }
127 
128 extern (C++) interface IDirect3DResource8 : IUnknown {
129     HRESULT GetDevice(IDirect3DDevice8* ppDevice);
130     HRESULT SetPrivateData(REFGUID refguid,const(void)* pData,DWORD SizeOfData,DWORD Flags);
131     HRESULT GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData);
132     HRESULT FreePrivateData(REFGUID refguid);
133     DWORD SetPriority(DWORD PriorityNew);
134     DWORD GetPriority();
135     void PreLoad();
136     D3DRESOURCETYPE GetType();
137 }
138 
139 extern (C++) interface IDirect3DBaseTexture8 : IDirect3DResource8 {
140     DWORD SetLOD(DWORD LODNew);
141     DWORD GetLOD();
142     DWORD GetLevelCount();
143 }
144 
145 extern (C++) interface IDirect3DTexture8 : IDirect3DBaseTexture8 {
146     HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc);
147     HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface8* ppSurfaceLevel);
148     HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,const(RECT)* pRect,DWORD Flags);
149     HRESULT UnlockRect(UINT Level);
150     HRESULT AddDirtyRect(const(RECT)* pDirtyRect);
151 }
152 
153 extern (C++) interface IDirect3DVolumeTexture8 : IDirect3DBaseTexture8 {
154     HRESULT GetLevelDesc(UINT Level,D3DVOLUME_DESC *pDesc);
155     HRESULT GetVolumeLevel(UINT Level,IDirect3DVolume8* ppVolumeLevel);
156     HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,const(D3DBOX)* pBox,DWORD Flags);
157     HRESULT UnlockBox(UINT Level);
158     HRESULT AddDirtyBox(const(D3DBOX)* pDirtyBox);
159 }
160 
161 extern (C++) interface IDirect3DCubeTexture8 : IDirect3DBaseTexture8 {
162     HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc);
163     HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8* ppCubeMapSurface);
164     HRESULT LockRect(D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,const(RECT)* pRect,DWORD Flags);
165     HRESULT UnlockRect(D3DCUBEMAP_FACES FaceType,UINT Level);
166     HRESULT AddDirtyRect(D3DCUBEMAP_FACES FaceType,const(RECT)* pDirtyRect);
167 }
168 
169 extern (C++) interface IDirect3DVertexBuffer8 : IDirect3DResource8 {}
170 extern (C++) interface IDirect3DIndexBuffer8  : IDirect3DResource8 {}
171 
172 extern (C++) interface IDirect3DSurface8 : IUnknown {
173     HRESULT GetDevice(IDirect3DDevice8* ppDevice);
174     HRESULT SetPrivateData(REFGUID refguid,const(void)* pData,DWORD SizeOfData,DWORD Flags);
175     HRESULT GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData);
176     HRESULT FreePrivateData(REFGUID refguid);
177     HRESULT GetContainer(REFIID riid,void** ppContainer);
178     HRESULT GetDesc(D3DSURFACE_DESC *pDesc);
179     HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,const(RECT)* pRect,DWORD Flags);
180     HRESULT UnlockRect();
181 }
182 
183 extern (C++) interface IDirect3DVolume8 : IUnknown {
184     HRESULT GetDevice(IDirect3DDevice8* ppDevice);
185     HRESULT SetPrivateData(REFGUID refguid,const(void)* pData,DWORD SizeOfData,DWORD Flags);
186     HRESULT GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData);
187     HRESULT FreePrivateData(REFGUID refguid);
188     HRESULT GetContainer(REFIID riid,void** ppContainer);
189     HRESULT GetDesc(D3DVOLUME_DESC *pDesc);
190     HRESULT LockBox(D3DLOCKED_BOX * pLockedVolume,const(D3DBOX)* pBox,DWORD Flags);
191     HRESULT UnlockBox();
192 }
193 
194 struct D3DVIEWPORT8 {
195     DWORD       X;
196     DWORD       Y;            /* Viewport Top left */
197     DWORD       Width;
198     DWORD       Height;       /* Viewport Dimensions */
199     float       MinZ;         /* Min/max of clip Volume */
200     float       MaxZ;
201 }
202 
203 struct D3DCLIPSTATUS8 {
204     DWORD ClipUnion;
205     DWORD ClipIntersection;
206 }
207 
208 struct D3DMATERIAL8 {
209     D3DCOLORVALUE   Diffuse;        /* Diffuse color RGBA */
210     D3DCOLORVALUE   Ambient;        /* Ambient color RGB */
211     D3DCOLORVALUE   Specular;       /* Specular 'shininess' */
212     D3DCOLORVALUE   Emissive;       /* Emissive color RGB */
213     float           Power;          /* Sharpness if specular highlight */
214 }
215 
216 struct D3DLIGHT8 {
217     D3DLIGHTTYPE    Type;            /* Type of light source */
218     D3DCOLORVALUE   Diffuse;         /* Diffuse color of light */
219     D3DCOLORVALUE   Specular;        /* Specular color of light */
220     D3DCOLORVALUE   Ambient;         /* Ambient color of light */
221     D3DVECTOR       Position;         /* Position in world space */
222     D3DVECTOR       Direction;        /* Direction in world space */
223     float           Range;            /* Cutoff range */
224     float           Falloff;          /* Falloff */
225     float           Attenuation0;     /* Constant attenuation */
226     float           Attenuation1;     /* Linear attenuation */
227     float           Attenuation2;     /* Quadratic attenuation */
228     float           Theta;            /* Inner angle of spotlight cone */
229     float           Phi;              /* Outer angle of spotlight cone */
230 }
231 
232 __gshared LPDIRECT3DCREATE8 Direct3DCreate8;
233 
234 extern (Windows) {
235     alias LPDIRECT3DCREATE8 = IDirect3D8 function(UINT SDKVersion);
236 }
237 
238 enum D3D_SDK_VERSION = 220;